package com.test;

import java.util.Scanner;

public class Xiaomeidezixuelie {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        String[] words = new String[n];
        for (int i = 0; i < n; i++){
            //改良
            String next = scanner.next();
            if (next.length() > m){
                System.out.println("输入的长度大于指定列宽");
                i--;
                continue;
            }
            words[i] = next;
        }
        String rs = "meituan";
        int len = rs.length();
        int idx = 0;
        for (int i = 0; i < n && idx < len; i++) {
            if (words[i].indexOf(rs.charAt(idx)) > -1){
                idx++;
            }
        }
        System.out.println(idx == len ? "YES" : "NO");
    }
}
